package com.learn.service.impl;

import com.learn.dao.empDao;
import com.learn.pojo.Emp;
import com.learn.service.empService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service //交给spring的ioc容器管理
public class empServiceB implements empService {
    @Autowired //di注入
    private empDao empDap;
    @Override
    public List<Emp> listEmp() {
        //调用dao层
        List<Emp> ems = empDap.listEmp();

        //处理数据
        ems.forEach(emp->{
            if("1".equals(emp.getGender())){
                emp.setGender("男士");
            }else{
                emp.setGender("lady");
            }

            if("1".equals(emp.getJob())){
                emp.setJob("讲师");
            }else if("2".equals(emp.getJob())){
                emp.setJob("班主任");
            }else{
                emp.setJob("就业指导");
            }
        });
        return ems;
    }
}
